<template>
  <div class="product" @click="toDetails">
    <div>
      <div class="product-image">
        <img class="image" :src="info.mainImg" alt="">
      </div>
      <div class="title">
        <!-- <t-platform class="type" :type="info.channel"></t-platform> -->
        {{ info.subject }}
      </div>
    </div>
    <span class="price">{{ currencySymbol }} <span>{{ info.price || 0 }}</span></span>
    <!--    <span class="num">{{$t('goods.volume')}}: {{info.monthSold}}</span>-->
    <div class="shop-name" v-if="false">
      <img class="logo" src="@/assets/images/login/banner.jpg" alt="">
      <span class="name">---</span>
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex';
import { toSeoFriendsChannel } from '@/common/common'
import TPlatform from "@/components/t-platform";
import { detailPoint } from '@/api/user';

export default {
  name: "product",
  components: { TPlatform },
  props: {
    info: Object,
    currencySymbol: String,
    index: Number,
    detailPosition: {
      type: Number,
      default: 0
    }
  },
  computed: {
    ...mapState({
      userInfo: state => state.user.userInfo,
    })
  },
  methods: {
    toDetails() {
      this.$emit('taobaoPoint', this.info.spuNo, this.index)
      const query = {
      }
      if (this.userInfo.inviteCode) {
        query.inviteCode = this.userInfo.inviteCode
      }
      const channelId = toSeoFriendsChannel(this.info.channel);
      let toUrl = this.$router.resolve({
        path: `/product/${channelId}/${this.info.spuNo}`,
        query
      });
      let data = {
        channel: 4,
        position: this.detailPosition,
        detailUrl: `${this.$store.state.config.config.webDomain}/product/${channelId}/${this.info.spuNo}`,
        productChannel: this.info.channel,
        productType: this.info.categoryName,
        spuNo: this.info.spuNo,
        price: this.info.price
      }
      detailPoint(data)
      window.open(toUrl.href);
    }
  }
}
</script>

<style scoped lang="less">
.product {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  border-radius: 4px;
  overflow: hidden;

  &:hover {
    transform: translateY(-10px);
    transition: .5s;

  }

  .product-image {
    display: block;
    width: 246px;
    height: 246px;
    overflow: hidden;
    border-radius: 10px;

    .image {
      width: 100%;
      max-height: 100%;
    }
  }

  .title {
    margin-top: 8px;
    font-family: PingFang HK, PingFang HK;
    font-weight: 400;
    font-size: 17px;
    color: #333333;
    line-height: 28px;
    cursor: pointer;
    white-space: pre-line;
    /*允许换行*/
    overflow: hidden;
    text-overflow: ellipsis;
    /*省略号*/
    display: -webkit-box;
    -webkit-box-orient: vertical;
    /*行向垂直排列*/
    -webkit-line-clamp: 2; //*限制2

    &:hover {
      color: @primary-color
    }

    .type {
      display: inline-block;
      vertical-align: top;
    }
  }

  .price {
    display: block;
    margin-top: 8px;
    margin-bottom: 2px;
    font-family: PingFang SC, PingFang SC;
    font-weight: 500;
    font-size: 14px;
    color: #FF186B;
    line-height: 18px;

    span {
      font-size: 16px;
      font-weight: 700;
    }
  }

  .num {
    color: @t-text-color;
    font-size: 12px;
    font-weight: 500;
  }

  .shop-name {
    display: flex;
    align-items: center;
    margin-top: 4px;

    .logo {
      display: block;
      margin-right: 6px;
      width: 24px;
      height: 24px;
      border-radius: 50%;
    }

    .name {
      color: @t-text-color;
      font-size: 12px;
      font-weight: 500;
    }
  }
}
</style>